import { Button, Form, Input, Select } from 'antd';
import React from 'react';

const { Option } = Select;

interface SearchFormProps {
  onSearch: (values: any) => void;
}

const SearchForm: React.FC<SearchFormProps> = ({ onSearch }) => {
  const [form] = Form.useForm();

  const handleReset = () => {
    form.resetFields();
    onSearch({});
  };

  return (
    <Form
      form={form}
      layout="inline"
      onFinish={onSearch}
    >
      <Form.Item name="jobName" label="任务名称">
        <Input placeholder="请输入任务名称" />
      </Form.Item>

      <Form.Item name="jobGroup" label="任务组">
        <Select placeholder="请选择任务组" style={{ width: 120 }}>
          <Option value="">全部</Option>
          <Option value="DEFAULT">默认</Option>
          <Option value="SYSTEM">系统</Option>
        </Select>
      </Form.Item>

      <Form.Item name="status" label="执行状态">
        <Select placeholder="请选择状态" style={{ width: 120 }}>
          <Option value="">全部</Option>
          <Option value="0">成功</Option>
          <Option value="1">失败</Option>
        </Select>
      </Form.Item>

      <Form.Item>
        <Button type="primary" htmlType="submit">
          搜索
        </Button>
        <Button style={{ marginLeft: 8 }} onClick={handleReset}>
          重置
        </Button>
      </Form.Item>
    </Form>
  );
};

export default SearchForm;
